<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Business extends Model
{
    protected $table = 'business';


    /**
     * 所有业务列表
     * @return mixed
     */
    public static function getBusinessList()
    {
        $list = self::select('id', 'name')->get();
        $data[0] = '充值';;
        if (!empty($list)) {
            foreach ($list as $key => $val) {
                $data[$val['id']] = $val['name'];
            }
        }
        return $data;
    }

    /**
     * 取业务
     * @param $business_id
     * @return string
     */
    public static function getBusiness($business_id)
    {
        return isset(self::getBusinessList()[$business_id]) ? self::getBusinessList()[$business_id] : '';
    }
}
